package sapling.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import sapling.model.Admin;

import java.util.List;

/**
 * Created by ever on 2016/10/9.
 */

@Transactional
public interface AdminDao extends JpaRepository<Admin, Long> {

    Admin findOneByUsername(String username);

    @Query(value = "SELECT * FROM admin WHERE company_id is null",nativeQuery = true)
    List<Admin> findNullCompany();

    @Query(value = "SELECT * FROM admin WHERE company_id is not null",nativeQuery = true)
    List<Admin> findCompany();

    List<Admin> findByUsernameNot(String username);

}
